package cn.sdormitory.controller.index;

import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.index.service.IndexDataService;
import cn.sdormitory.school.entity.SchoolDuty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index/data")
public class IndexDataController {

    @Autowired
    IndexDataService indexdataService;

    @ApiOperation("查询前一天宿舍考勤数据")
    @RequestMapping("/findLastDaySdAttenceData")
    public CommonResult findLastDaySdAttenceData(){
        List<Map<String, Object>> lastDaySdAttenceData = indexdataService.findLastDaySdAttenceData();
        return CommonResult.success(lastDaySdAttenceData);
    }

    @ApiOperation("查询班级一周请假情况")
    @RequestMapping("/findClassWeekLeaveData")
    public CommonResult findClassWeekLeaveData(){
        List<Map<String, Object>> weekLeaveData = indexdataService.findClassWeekLeaveData();
        return CommonResult.success(weekLeaveData);
    }

    @ApiOperation("查询班级当天出勤情况")
    @RequestMapping("/findTodayClassAttenceData")
    public CommonResult findTodayClassAttenceData(){
        List<Map<String, Object>> todayClassAttenceData = indexdataService.findTodayClassAttenceData();
        return CommonResult.success(todayClassAttenceData);
    }

    @ApiOperation("查询宿舍报修数量")
    @RequestMapping("/findSdRepairCount")
    public CommonResult findSdRepairCount(){
        Map<String,Object> sdRepairCount = indexdataService.findSdRepairCount();
        return CommonResult.success(sdRepairCount);
    }

    @ApiOperation("查询班级报修数量")
    @RequestMapping("/findClassRepairCount")
    public CommonResult findClassRepairCount(){
        Map<String,Object> clsRepairCount = indexdataService.findClassRepairCount();
        return CommonResult.success(clsRepairCount);
    }

    @ApiOperation("查询当天值班人员")
    @RequestMapping("/findTodayDutyPerson")
    public CommonResult findTodayDutyPerson(){
        List<SchoolDuty> dutyPersonList = indexdataService.findTodayDutyPerson();
        return CommonResult.success(dutyPersonList);
    }

    @ApiOperation("查询违纪数量")
    @RequestMapping("/findDvCount")
    public CommonResult findDvCount(){
        List<Map<String, Object>> dvCount = indexdataService.findDvCount();
        return CommonResult.success(dvCount);
    }


}
